package br.org.bertol.mestrado.engine.optimisation.pso;

import java.util.Collections;
import java.util.List;

import br.org.bertol.mestrado.engine.optimisation.Operacao;
import br.org.bertol.mestrado.engine.optimisation.entity.Particle;

public enum TypeMovement implements Operacao<Particle> {
    CLERC {
        @Override
        public void execute(final Particle particle) {

            for (Velocity velocity : particle.getSpeed()) {

                // usando vers�o do algoritmo de clerc para trocar indices

                // pega os �ndices dos elementos
                final int indexClasse1 = particle.getRoute()
                        .indexOf(
                                 velocity.getPar1());

                final int indexClasse2 = particle.getRoute()
                        .indexOf(
                                 velocity.getPar2());

                // troca os elementos
                Collections.swap(particle.getRoute(), indexClasse1,
                                 indexClasse2);
            }
        }
        },
    WANG {
        @Override
        public void execute(final Particle particle) {

            final List<Velocity> speed = particle.getSpeed();

            final List<Integer> route = particle.getRoute();

            for (int i = 0; i < particle.getSpeed().size(); i++) {
                final Velocity v = speed.get(i);

                // usando vers�o do algoritmo de wang para trocar indices
                Collections.swap(route, v.getPar1(), v.getPar2());
            }
        }
        },
}
